package com.lw.acl.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lw.acl.entity.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author testjava
 * @since 2020-01-12
 */
public interface UserMapper extends BaseMapper<User> {

    @Select( "select * from acl_user where username=#{username}" )
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "username",column = "username"),
            @Result(property = "password",column = "password"),
            @Result(property = "nickName",column = "nick_name"),
            @Result(property = "salt",column = "salt"),
            @Result(property = "token",column = "token"),
            @Result(property = "isDeleted",column = "is_deleted"),
            @Result(property = "gmtCreate",column = "gmt_create"),
            @Result(property = "gmtModified",column = "gmt_modified"),
            @Result(property = "roles",column = "id",javaType = java.util.List.class,many = @Many(select = "com.lw.acl.mapper.RoleMapper.findById"))
    })
    User selectByUsername(String username);
}
